﻿/*
* 
*
* 功 能： N/A
* 类 名： BDPULL
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* 
*/
using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;

using DQYT.HTDZ.IDAL;
using Maticsoft.DBUtility;
using DQYT.HTDZ.Model;

namespace DQYT.HTDZ.OracleDAL
{
	/// <summary>
	/// 数据访问类:BDPULL
	/// </summary>
	public partial class BDPULLDAL:IBDPULL
	{
		public BDPULLDAL()
		{}
		#region  BasicMethod

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(decimal PULLID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from BDPULL");
			strSql.Append(" where PULLID=:PULLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":PULLID", OracleType.Number,22)			};
			parameters[0].Value = PULLID;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(BDPULLModel model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into BDPULL(");
			strSql.Append("PULLID,CYJXH,CYJLB,SCCJ,XDEDZH,GGZDCC,GGZDCCI,JSQEDNJ,JSQXSDH,PHFS,LGC,QBC,HBC,QBZL,QBZXBJ,QBZX,PDXHGG,PHKSL,JSB,ZJZL,ZJCC,JNCYJ,SCFS,JXFLM,ISVALID,ISUSED,BJ)");
			strSql.Append(" values (");
			strSql.Append(":PULLID,:CYJXH,:CYJLB,:SCCJ,:XDEDZH,:GGZDCC,:GGZDCCI,:JSQEDNJ,:JSQXSDH,:PHFS,:LGC,:QBC,:HBC,:QBZL,:QBZXBJ,:QBZX,:PDXHGG,:PHKSL,:JSB,:ZJZL,:ZJCC,:JNCYJ,:SCFS,:JXFLM,:ISVALID,:ISUSED,:BJ)");
			OracleParameter[] parameters = {
					new OracleParameter(":PULLID", OracleType.Number,18),
					new OracleParameter(":CYJXH", OracleType.VarChar,30),
					new OracleParameter(":CYJLB", OracleType.VarChar,30),
					new OracleParameter(":SCCJ", OracleType.VarChar,30),
					new OracleParameter(":XDEDZH", OracleType.Float,22),
					new OracleParameter(":GGZDCC", OracleType.Float,22),
					new OracleParameter(":GGZDCCI", OracleType.Float,22),
					new OracleParameter(":JSQEDNJ", OracleType.Float,22),
					new OracleParameter(":JSQXSDH", OracleType.VarChar,30),
					new OracleParameter(":PHFS", OracleType.VarChar,30),
					new OracleParameter(":LGC", OracleType.Float,22),
					new OracleParameter(":QBC", OracleType.Float,22),
					new OracleParameter(":HBC", OracleType.Float,22),
					new OracleParameter(":QBZL", OracleType.Float,22),
					new OracleParameter(":QBZXBJ", OracleType.Float,22),
					new OracleParameter(":QBZX", OracleType.VarChar,30),
					new OracleParameter(":PDXHGG", OracleType.VarChar,30),
					new OracleParameter(":PHKSL", OracleType.Float,22),
					new OracleParameter(":JSB", OracleType.Float,22),
					new OracleParameter(":ZJZL", OracleType.Float,22),
					new OracleParameter(":ZJCC", OracleType.Float,22),
					new OracleParameter(":JNCYJ", OracleType.VarChar,30),
					new OracleParameter(":SCFS", OracleType.VarChar,30),
					new OracleParameter(":JXFLM", OracleType.VarChar,30),
					new OracleParameter(":ISVALID", OracleType.Number,4),
					new OracleParameter(":ISUSED", OracleType.Number,4),
					new OracleParameter(":BJ", OracleType.VarChar,300)};
			parameters[0].Value = model.PULLID;
			parameters[1].Value = model.CYJXH;
			parameters[2].Value = model.CYJLB;
			parameters[3].Value = model.SCCJ;
			parameters[4].Value = model.XDEDZH;
			parameters[5].Value = model.GGZDCC;
			parameters[6].Value = model.GGZDCCI;
			parameters[7].Value = model.JSQEDNJ;
			parameters[8].Value = model.JSQXSDH;
			parameters[9].Value = model.PHFS;
			parameters[10].Value = model.LGC;
			parameters[11].Value = model.QBC;
			parameters[12].Value = model.HBC;
			parameters[13].Value = model.QBZL;
			parameters[14].Value = model.QBZXBJ;
			parameters[15].Value = model.QBZX;
			parameters[16].Value = model.PDXHGG;
			parameters[17].Value = model.PHKSL;
			parameters[18].Value = model.JSB;
			parameters[19].Value = model.ZJZL;
			parameters[20].Value = model.ZJCC;
			parameters[21].Value = model.JNCYJ;
			parameters[22].Value = model.SCFS;
			parameters[23].Value = model.JXFLM;
			parameters[24].Value = model.ISVALID;
			parameters[25].Value = model.ISUSED;
			parameters[26].Value = model.BJ;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
        public bool Update(BDPULLModel model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update BDPULL set ");
			strSql.Append("CYJXH=:CYJXH,");
			strSql.Append("CYJLB=:CYJLB,");
			strSql.Append("SCCJ=:SCCJ,");
			strSql.Append("XDEDZH=:XDEDZH,");
			strSql.Append("GGZDCC=:GGZDCC,");
			strSql.Append("GGZDCCI=:GGZDCCI,");
			strSql.Append("JSQEDNJ=:JSQEDNJ,");
			strSql.Append("JSQXSDH=:JSQXSDH,");
			strSql.Append("PHFS=:PHFS,");
			strSql.Append("LGC=:LGC,");
			strSql.Append("QBC=:QBC,");
			strSql.Append("HBC=:HBC,");
			strSql.Append("QBZL=:QBZL,");
			strSql.Append("QBZXBJ=:QBZXBJ,");
			strSql.Append("QBZX=:QBZX,");
			strSql.Append("PDXHGG=:PDXHGG,");
			strSql.Append("PHKSL=:PHKSL,");
			strSql.Append("JSB=:JSB,");
			strSql.Append("ZJZL=:ZJZL,");
			strSql.Append("ZJCC=:ZJCC,");
			strSql.Append("JNCYJ=:JNCYJ,");
			strSql.Append("SCFS=:SCFS,");
			strSql.Append("JXFLM=:JXFLM,");
			strSql.Append("ISVALID=:ISVALID,");
			strSql.Append("ISUSED=:ISUSED,");
			strSql.Append("BJ=:BJ");
			strSql.Append(" where PULLID=:PULLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":CYJXH", OracleType.VarChar,30),
					new OracleParameter(":CYJLB", OracleType.VarChar,30),
					new OracleParameter(":SCCJ", OracleType.VarChar,30),
					new OracleParameter(":XDEDZH", OracleType.Float,22),
					new OracleParameter(":GGZDCC", OracleType.Float,22),
					new OracleParameter(":GGZDCCI", OracleType.Float,22),
					new OracleParameter(":JSQEDNJ", OracleType.Float,22),
					new OracleParameter(":JSQXSDH", OracleType.VarChar,30),
					new OracleParameter(":PHFS", OracleType.VarChar,30),
					new OracleParameter(":LGC", OracleType.Float,22),
					new OracleParameter(":QBC", OracleType.Float,22),
					new OracleParameter(":HBC", OracleType.Float,22),
					new OracleParameter(":QBZL", OracleType.Float,22),
					new OracleParameter(":QBZXBJ", OracleType.Float,22),
					new OracleParameter(":QBZX", OracleType.VarChar,30),
					new OracleParameter(":PDXHGG", OracleType.VarChar,30),
					new OracleParameter(":PHKSL", OracleType.Float,22),
					new OracleParameter(":JSB", OracleType.Float,22),
					new OracleParameter(":ZJZL", OracleType.Float,22),
					new OracleParameter(":ZJCC", OracleType.Float,22),
					new OracleParameter(":JNCYJ", OracleType.VarChar,30),
					new OracleParameter(":SCFS", OracleType.VarChar,30),
					new OracleParameter(":JXFLM", OracleType.VarChar,30),
					new OracleParameter(":ISVALID", OracleType.Number,4),
					new OracleParameter(":ISUSED", OracleType.Number,4),
					new OracleParameter(":BJ", OracleType.VarChar,300),
					new OracleParameter(":PULLID", OracleType.Number,18)};
			parameters[0].Value = model.CYJXH;
			parameters[1].Value = model.CYJLB;
			parameters[2].Value = model.SCCJ;
			parameters[3].Value = model.XDEDZH;
			parameters[4].Value = model.GGZDCC;
			parameters[5].Value = model.GGZDCCI;
			parameters[6].Value = model.JSQEDNJ;
			parameters[7].Value = model.JSQXSDH;
			parameters[8].Value = model.PHFS;
			parameters[9].Value = model.LGC;
			parameters[10].Value = model.QBC;
			parameters[11].Value = model.HBC;
			parameters[12].Value = model.QBZL;
			parameters[13].Value = model.QBZXBJ;
			parameters[14].Value = model.QBZX;
			parameters[15].Value = model.PDXHGG;
			parameters[16].Value = model.PHKSL;
			parameters[17].Value = model.JSB;
			parameters[18].Value = model.ZJZL;
			parameters[19].Value = model.ZJCC;
			parameters[20].Value = model.JNCYJ;
			parameters[21].Value = model.SCFS;
			parameters[22].Value = model.JXFLM;
			parameters[23].Value = model.ISVALID;
			parameters[24].Value = model.ISUSED;
			parameters[25].Value = model.BJ;
			parameters[26].Value = model.PULLID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(decimal PULLID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from BDPULL ");
			strSql.Append(" where PULLID=:PULLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":PULLID", OracleType.Number,22)			};
			parameters[0].Value = PULLID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string PULLIDlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from BDPULL ");
			strSql.Append(" where PULLID in ("+PULLIDlist + ")  ");
			int rows=DbHelperOra.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BDPULLModel GetModel(decimal PULLID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select PULLID,CYJXH,CYJLB,SCCJ,XDEDZH,GGZDCC,GGZDCCI,JSQEDNJ,JSQXSDH,PHFS,LGC,QBC,HBC,QBZL,QBZXBJ,QBZX,PDXHGG,PHKSL,JSB,ZJZL,ZJCC,JNCYJ,SCFS,JXFLM,ISVALID,ISUSED,BJ from BDPULL ");
			strSql.Append(" where PULLID=:PULLID ");
			OracleParameter[] parameters = {
					new OracleParameter(":PULLID", OracleType.Number,22)			};
			parameters[0].Value = PULLID;

			BDPULLDAL model=new BDPULLDAL();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BDPULLModel DataRowToModel(DataRow row)
		{
			BDPULLModel model=new BDPULLModel();
			if (row != null)
			{
				if(row["PULLID"]!=null && row["PULLID"].ToString()!="")
				{
					model.PULLID=decimal.Parse(row["PULLID"].ToString());
				}
				if(row["CYJXH"]!=null)
				{
					model.CYJXH=row["CYJXH"].ToString();
				}
				if(row["CYJLB"]!=null)
				{
					model.CYJLB=row["CYJLB"].ToString();
				}
				if(row["SCCJ"]!=null)
				{
					model.SCCJ=row["SCCJ"].ToString();
				}
				if(row["XDEDZH"]!=null && row["XDEDZH"].ToString()!="")
				{
					model.XDEDZH=decimal.Parse(row["XDEDZH"].ToString());
				}
				if(row["GGZDCC"]!=null && row["GGZDCC"].ToString()!="")
				{
					model.GGZDCC=decimal.Parse(row["GGZDCC"].ToString());
				}
				if(row["GGZDCCI"]!=null && row["GGZDCCI"].ToString()!="")
				{
					model.GGZDCCI=decimal.Parse(row["GGZDCCI"].ToString());
				}
				if(row["JSQEDNJ"]!=null && row["JSQEDNJ"].ToString()!="")
				{
					model.JSQEDNJ=decimal.Parse(row["JSQEDNJ"].ToString());
				}
				if(row["JSQXSDH"]!=null)
				{
					model.JSQXSDH=row["JSQXSDH"].ToString();
				}
				if(row["PHFS"]!=null)
				{
					model.PHFS=row["PHFS"].ToString();
				}
				if(row["LGC"]!=null && row["LGC"].ToString()!="")
				{
					model.LGC=decimal.Parse(row["LGC"].ToString());
				}
				if(row["QBC"]!=null && row["QBC"].ToString()!="")
				{
					model.QBC=decimal.Parse(row["QBC"].ToString());
				}
				if(row["HBC"]!=null && row["HBC"].ToString()!="")
				{
					model.HBC=decimal.Parse(row["HBC"].ToString());
				}
				if(row["QBZL"]!=null && row["QBZL"].ToString()!="")
				{
					model.QBZL=decimal.Parse(row["QBZL"].ToString());
				}
				if(row["QBZXBJ"]!=null && row["QBZXBJ"].ToString()!="")
				{
					model.QBZXBJ=decimal.Parse(row["QBZXBJ"].ToString());
				}
				if(row["QBZX"]!=null)
				{
					model.QBZX=row["QBZX"].ToString();
				}
				if(row["PDXHGG"]!=null)
				{
					model.PDXHGG=row["PDXHGG"].ToString();
				}
				if(row["PHKSL"]!=null && row["PHKSL"].ToString()!="")
				{
					model.PHKSL=decimal.Parse(row["PHKSL"].ToString());
				}
				if(row["JSB"]!=null && row["JSB"].ToString()!="")
				{
					model.JSB=decimal.Parse(row["JSB"].ToString());
				}
				if(row["ZJZL"]!=null && row["ZJZL"].ToString()!="")
				{
					model.ZJZL=decimal.Parse(row["ZJZL"].ToString());
				}
				if(row["ZJCC"]!=null && row["ZJCC"].ToString()!="")
				{
					model.ZJCC=decimal.Parse(row["ZJCC"].ToString());
				}
				if(row["JNCYJ"]!=null)
				{
					model.JNCYJ=row["JNCYJ"].ToString();
				}
				if(row["SCFS"]!=null)
				{
					model.SCFS=row["SCFS"].ToString();
				}
				if(row["JXFLM"]!=null)
				{
					model.JXFLM=row["JXFLM"].ToString();
				}
				if(row["ISVALID"]!=null && row["ISVALID"].ToString()!="")
				{
					model.ISVALID=decimal.Parse(row["ISVALID"].ToString());
				}
				if(row["ISUSED"]!=null && row["ISUSED"].ToString()!="")
				{
					model.ISUSED=decimal.Parse(row["ISUSED"].ToString());
				}
				if(row["BJ"]!=null)
				{
					model.BJ=row["BJ"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select PULLID,CYJXH,CYJLB,SCCJ,XDEDZH,GGZDCC,GGZDCCI,JSQEDNJ,JSQXSDH,PHFS,LGC,QBC,HBC,QBZL,QBZXBJ,QBZX,PDXHGG,PHKSL,JSB,ZJZL,ZJCC,JNCYJ,SCFS,JXFLM,ISVALID,ISUSED,BJ ");
			strSql.Append(" FROM BDPULL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM BDPULL ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.PULLID desc");
			}
			strSql.Append(")AS Row, T.*  from BDPULL T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "BDPULL";
			parameters[1].Value = "PULLID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod

 
    }
}

